package com.taoyusen.jpf.dao.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.taoyusen.common.base.impl.BaseDAOImpl;
import com.taoyusen.jpf.dao.IUserInfoDao;
import com.taoyusen.jpf.dao.pojo.TSysUserinfo;

public class UserInFoDaoImpl extends BaseDAOImpl<TSysUserinfo,String> 
	implements IUserInfoDao
{


	protected Class getPOJOClass() 
	{
		return TSysUserinfo.class;
	}

	public TSysUserinfo getUserInfoById(String userId) throws Exception 
	{
		return this.getObjectById(userId);
	}

	public List<TSysUserinfo> getUserInfoByMap(Map<String, Object> userMap) throws Exception
	{
		List<TSysUserinfo> resultList = new ArrayList<TSysUserinfo>();
		
		StringBuffer hql = new StringBuffer();
		hql.append(" from TSysUserinfo where 1=1");
		if(userMap.containsKey("userId"))
		{
			hql.append(" and userId = '"+userMap.get("userId")+"'");
		}
		if(userMap.containsKey("userName"))
		{
			hql.append(" and userName ='"+userMap.get("userName")+"'");
		}
		if(userMap.containsKey("userCode"))
		{
			hql.append(" and userCode ='"+userMap.get("userCode")+"'");
		}
	
		return resultList = this.createQuery(hql.toString()).list();

	}

	public List<TSysUserinfo> getUserInfoByUserName(String userName) throws Exception
	{
		List<TSysUserinfo> resultList = new ArrayList<TSysUserinfo>();
		StringBuffer hql = new StringBuffer();
		hql.append(" from TSysUserinfo where 1=1");
		if(userName != null && !"".equals("userName"))
		{
			hql.append(" and userName like '%"+userName+"%'");
		}
		
		return resultList = this.createQuery(hql.toString()).list();
	}

}
